
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>常用工具类 · GitBook</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.2">
        
        
        
    
    <link rel="stylesheet" href="gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="http.html" />
    
    
    <link rel="prev" href="rxjava.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        <li class="header">----安卓 UI----</li>
        
        
    
        <li class="chapter " data-level="1.1" data-path="./">
            
                <a href="./">
            
                    
                    Introduction
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="view.html">
            
                <a href="view.html">
            
                    
                    自定义控件和measure
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="canvas-paint.html">
            
                <a href="canvas-paint.html">
            
                    
                    draw和canvas，paint详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="anim.html">
            
                <a href="anim.html">
            
                    
                    动画
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="notify.html">
            
                <a href="notify.html">
            
                    
                    notify系列库
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="loading.html">
            
                <a href="loading.html">
            
                    
                    loading系列库
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="status-ui.html">
            
                <a href="status-ui.html">
            
                    
                    StatusUI系列库
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="touch-scroll.html">
            
                <a href="touch-scroll.html">
            
                    
                    滑动
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9" data-path="layout.html">
            
                <a href="layout.html">
            
                    
                    Layout
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10" data-path="textview.html">
            
                <a href="textview.html">
            
                    
                    TextView
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11" data-path="drawable.html">
            
                <a href="drawable.html">
            
                    
                    Drawable
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12" data-path="item-template.html">
            
                <a href="item-template.html">
            
                    
                    列表Adapter模板化
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13" data-path="recyclerview.html">
            
                <a href="recyclerview.html">
            
                    
                    RecyclerView全解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.14" data-path="design.html">
            
                <a href="design.html">
            
                    
                    MeterialDesign详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.15" data-path="component.html">
            
                <a href="component.html">
            
                    
                    AyoComponent基础库--Activity和Fragment
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.16" data-path="systembartint.html">
            
                <a href="systembartint.html">
            
                    
                    SystembarTint
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.17" data-path="permission-ask.html">
            
                <a href="permission-ask.html">
            
                    
                    权限控制
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.18" data-path="keyboard.html">
            
                <a href="keyboard.html">
            
                    
                    小键盘
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.19" data-path="notification.html">
            
                <a href="notification.html">
            
                    
                    Notification
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">----安卓 foundation----</li>
        
        
    
        <li class="chapter " data-level="2.1" data-path="mvp.html">
            
                <a href="mvp.html">
            
                    
                    MVP
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2" data-path="rxjava.html">
            
                <a href="rxjava.html">
            
                    
                    RxJava
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="2.3" data-path="lang.html">
            
                <a href="lang.html">
            
                    
                    常用工具类
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.4" data-path="http.html">
            
                <a href="http.html">
            
                    
                    http
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.5" data-path="xml.html">
            
                <a href="xml.html">
            
                    
                    xml解析
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.6" data-path="json-reporter.html">
            
                <a href="json-reporter.html">
            
                    
                    Json解析
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.7" data-path="inject.html">
            
                <a href="inject.html">
            
                    
                    ButterKnife
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.8" data-path="thread.html">
            
                <a href="thread.html">
            
                    
                    安卓线程和looper
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.9" data-path="process.html">
            
                <a href="process.html">
            
                    
                    多进程
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.10" data-path="eventbus.html">
            
                <a href="eventbus.html">
            
                    
                    EventBus
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.11" data-path="db.html">
            
                <a href="db.html">
            
                    
                    数据库和ContentProvider
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.12" data-path="job.html">
            
                <a href="job.html">
            
                    
                    定时任务
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.13" data-path="service.html">
            
                <a href="service.html">
            
                    
                    service
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.14" data-path="opt-mem.html">
            
                <a href="opt-mem.html">
            
                    
                    内存优化
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.15" data-path="opt-network.html">
            
                <a href="opt-network.html">
            
                    
                    网络优化
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.16" data-path="opt-anr.html">
            
                <a href="opt-anr.html">
            
                    
                    anr排查
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.17" data-path="opt-ui.html">
            
                <a href="opt-ui.html">
            
                    
                    UI卡顿优化
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.18" data-path="opt-launch.html">
            
                <a href="opt-launch.html">
            
                    
                    启动优化
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.19" data-path="opt-launch.html">
            
                <a href="opt-launch.html">
            
                    
                    混淆
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.20" data-path="hotfix.html">
            
                <a href="hotfix.html">
            
                    
                    热补丁混淆
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.21" data-path="aar.html">
            
                <a href="aar.html">
            
                    
                    aar相关
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.22" data-path="route.html">
            
                <a href="route.html">
            
                    
                    Route路由
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.23" data-path="modules.html">
            
                <a href="modules.html">
            
                    
                    分模块，组件化，插件化
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">----Gradle----</li>
        
        
    
        <li class="chapter " data-level="3.1" data-path="gradle.html">
            
                <a href="gradle.html">
            
                    
                    gradle基本配置
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.2" data-path="gradle-plugin.html">
            
                <a href="gradle-plugin.html">
            
                    
                    gradle插件开发
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">----工具----</li>
        
        
    
        <li class="chapter " data-level="4.1" data-path="repos.html">
            
                <a href="repos.html">
            
                    
                    优秀博客，开源项目
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.2" data-path="packs.html">
            
                <a href="packs.html">
            
                    
                    自动打包，多渠道打包
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.3" data-path="gist.html">
            
                <a href="gist.html">
            
                    
                    代码片段和常见问题
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.4" data-path="stetho.html">
            
                <a href="stetho.html">
            
                    
                    stetho
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.5" data-path="fabric.html">
            
                <a href="fabric.html">
            
                    
                    fabric
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.6" data-path="app-update.html">
            
                <a href="app-update.html">
            
                    
                    自动升级
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.7" data-path="bugsnags.html">
            
                <a href="bugsnags.html">
            
                    
                    日志和崩溃统计
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.8" data-path="mail.html">
            
                <a href="mail.html">
            
                    
                    发邮件辅助接口
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.9" data-path="socail.html">
            
                <a href="socail.html">
            
                    
                    第三方登录和分享
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.10" data-path="pay-alipay.html">
            
                <a href="pay-alipay.html">
            
                    
                    支付宝支付
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.11" data-path="pay-wx.html">
            
                <a href="pay-wx.html">
            
                    
                    微信支付
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.12" data-path="umeng.html">
            
                <a href="umeng.html">
            
                    
                    友盟统计
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.13" data-path="push-jpush.html">
            
                <a href="push-jpush.html">
            
                    
                    推送-极光
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.14" data-path="push-xiaomi.html">
            
                <a href="push-xiaomi.html">
            
                    
                    推送-小米
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="." >常用工具类</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <p>&#x5E38;&#x7528;&#x5DE5;&#x5177;&#x7C7B;&#xFF0C;java&#x51FD;&#x6570;&#x7CD6;&#xFF0C;&#x5B89;&#x5353;&#x51FD;&#x6570;&#x7CD6;</p>
<p>&#x6CA1;&#x6574;&#x5230;jcenter&#x4E0A;&#xFF0C;&#x6682;&#x65F6;&#x5C31;&#x7528;aar&#x5305;&#x5427;&#xFF0C;&#x4E5F;&#x633A;&#x7701;&#x52B2; 
&#x4E0B;&#x8F7D;&#x4E0B;&#x6765;&#x6587;&#x4EF6;&#x540D;&#x662F;&#xFF1A;ayo-lang.aar&#xFF0C;&#x62F7;&#x5230;libs&#x76EE;&#x5F55;&#x91CC;<br>&#x7136;&#x540E;&#x5728;build.gradle&#x91CC;&#x5F15;&#x5165;&#xFF1A;</p>
<pre><code>repositories {
    flatDir {
        dirs &apos;libs&apos;
    }
}

compile(name:&apos;ayo-lang&apos;, ext:&apos;aar&apos;)
</code></pre><ul>
<li>&#x7B2C;&#x4E09;&#x65B9;&#x4F9D;&#x8D56;&#xFF1A;<ul>
<li>fastjson&#xFF1A;compile &apos;com.alibaba:fastjson:1.2.8&apos;&#xFF0C;&#x8BF7;&#x6CE8;&#x610F;&#x7248;&#x672C;</li>
</ul>
</li>
</ul>
<h2 id="1-&#x521D;&#x59CB;&#x5316;">1 &#x521D;&#x59CB;&#x5316;</h2>
<p>&#x521D;&#x59CB;&#x5316;&#x5728;Application.onCreate()&#x91CC;</p>
<pre><code class="lang-java"><span class="hljs-keyword">package</span> com.cowthan.sample;

<span class="hljs-keyword">import</span> android.app.Application;
<span class="hljs-keyword">import</span> org.ayo.Ayo;

<span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">App</span> <span class="hljs-keyword">extends</span> <span class="hljs-title">Application</span></span>{

    <span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> Application app;

    <span class="hljs-meta">@Override</span>
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">onCreate</span><span class="hljs-params">()</span> </span>{
        <span class="hljs-keyword">super</span>.onCreate();
        app = <span class="hljs-keyword">this</span>;

        <span class="hljs-comment">//&#x521D;&#x59CB;&#x5316;AyoSDK</span>
        Ayo.init(<span class="hljs-keyword">this</span>, <span class="hljs-string">&quot;ayo&quot;</span>, <span class="hljs-keyword">true</span>, <span class="hljs-keyword">true</span>);
    }
}
</code></pre>
<p>&#x8981;&#x8BBF;&#x95EE;&#x5168;&#x5C40;&#x4E0A;&#x4E0B;&#x6587;&#xFF0C;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;<code>App.app</code>&#x6216;<code>Ayo.context</code></p>
<h2 id="2-&#x5E38;&#x7528;&#x5DE5;&#x5177;&#x7C7B;">2 &#x5E38;&#x7528;&#x5DE5;&#x5177;&#x7C7B;</h2>
<ul>
<li>&#x5E38;&#x7528;&#x5DE5;&#x5177;&#x7C7B;<ul>
<li>Lang</li>
<li>&#x96C6;&#x5408;&#x5DE5;&#x5177;&#x7C7B; Lists</li>
<li>&#x5B57;&#x7B26;&#x4E32;&#x5DE5;&#x5177;&#x7C7B; Strings</li>
<li>&#x5B89;&#x5353;&#x7CFB;&#x7EDF;Intent</li>
<li>&#x624B;&#x673A;&#x4FE1;&#x606F;&#x8BBF;&#x95EE;</li>
<li>App&#x4FE1;&#x606F;&#x8BBF;&#x95EE;</li>
<li>&#x65E5;&#x671F;&#x5DE5;&#x5177;&#x7C7B;</li>
<li>IP&#x5730;&#x5740;</li>
</ul>
</li>
</ul>
<p>java&#x8BED;&#x6CD5;&#x7CD6;&#xFF0C;&#x51FD;&#x6570;&#x7CD6;&#xFF0C;&#x4E00;&#x822C;&#x90FD;&#x5728;org.ayo.lang&#x4E2D;</p>
<h3 id="1-&#x5224;&#x7A7A;&#x7CFB;&#x5217;">1 &#x5224;&#x7A7A;&#x7CFB;&#x5217;</h3>
<pre><code class="lang-java">Lang.isEmpty(String)
Lang.isEmpty(Collection&lt;?&gt;)
Lang.isNull(Object)

&#x8FD8;&#x6709;&#x5BF9;&#x5E94;&#x7684;isNotEmpty, isNotNull
</code></pre>
<h3 id="2-&#x957F;&#x5EA6;&#x7CFB;&#x5217;">2 &#x957F;&#x5EA6;&#x7CFB;&#x5217;</h3>
<pre><code class="lang-java">Lang.count(List&#x6216;&#x8005;&#x6570;&#x7EC4;&#xFF0C;&#x6216;&#x8005;String)
</code></pre>
<h3 id="3-equals&#x548C;tostring">3 equals&#x548C;toString</h3>
<pre><code class="lang-java">Lang.equals(o1, o2)
Lang.toString(o1)
Lang.equalsIgnoreCase(String, String)
</code></pre>
<h3 id="4-snull&#x65B9;&#x6CD5;&#xFF1A;string&#x4E3A;null&#x65F6;&#x7684;&#x66FF;&#x6362;">4 snull&#x65B9;&#x6CD5;&#xFF1A;String&#x4E3A;null&#x65F6;&#x7684;&#x66FF;&#x6362;</h3>
<pre><code class="lang-java">String s = Lang.snull(<span class="hljs-string">&quot;&#x53EF;&#x80FD;&#x4E3A;null&#x7684;&#x5B57;&#x7B26;&#x4E32;&quot;</span>, <span class="hljs-string">&quot;&#x5982;&#x679C;&#x4E3A;null&#xFF0C;&#x5219;&#x8FD4;&#x56DE;&#x8FD9;&#x4E2A;&quot;</span>);
</code></pre>
<h3 id="5-&#x6570;&#x7EC4;&#x548C;&#x96C6;&#x5408;&#x64CD;&#x4F5C;&#xFF1A;lang&#x548C;lists-maps">5 &#x6570;&#x7EC4;&#x548C;&#x96C6;&#x5408;&#x64CD;&#x4F5C;&#xFF1A;Lang&#x548C;Lists, Maps</h3>
<pre><code class="lang-java"><span class="hljs-comment">//&#x6570;&#x7EC4;&#x548C;List&#x7684;&#x521B;&#x5EFA;</span>
String[] ss = Lang.array(<span class="hljs-string">&quot;A&quot;</span>,<span class="hljs-string">&quot;B&quot;</span>,<span class="hljs-string">&quot;C&quot;</span>);
List&lt;Object&gt; list =  Lang.list(<span class="hljs-string">&quot;true&quot;</span>, <span class="hljs-string">&quot;23&quot;</span>, <span class="hljs-string">&quot;ABC&quot;</span>);
List&lt;Object&gt; list =  Lists.newArrayList(<span class="hljs-string">&quot;true&quot;</span>, <span class="hljs-string">&quot;23&quot;</span>, <span class="hljs-string">&quot;ABC&quot;</span>);
Set&lt;Object&gt; set= Lang.set(<span class="hljs-string">&quot;true&quot;</span>, <span class="hljs-string">&quot;23&quot;</span>, <span class="hljs-string">&quot;ABC&quot;</span>);

<span class="hljs-comment">//contains</span>
contains&#xFF1A;&#x9488;&#x5BF9;&#x6570;&#x7EC4;&#x548C;List&#xFF0C;Set&#xFF0C;&#x6570;&#x7EC4;
containsKey&#x548C;containsValue&#xFF1A;&#x9488;&#x5BF9;map

<span class="hljs-comment">//&#x5143;&#x7D20;&#x8BBF;&#x95EE;&#xFF0C;&#x65E0;&#x5219;&#x7ED9;null</span>
Object ele = Lists.lastElement(list);  <span class="hljs-comment">//&#x6700;&#x540E;&#x4E00;&#x4E2A;&#x5143;&#x7D20;</span>
Object ele = Lists.firstElement(list); <span class="hljs-comment">//&#x7B2C;&#x4E00;&#x4E2A;&#x5143;&#x7D20;</span>

<span class="hljs-comment">//&#x5143;&#x7D20;&#x7B5B;&#x9009;</span>
List&lt;T&gt; list = Lists.killTraitors(List&lt;T&gt; ours, List&lt;T&gt; traitors); <span class="hljs-comment">//&#x4ECE;ours&#x4E2D;&#x5220;&#x6389;traitor&#x5305;&#x542B;&#x7684;&#x5143;&#x7D20;&#xFF0C;&#x57FA;&#x4E8E;contains&#x548C;equals&#x65B9;&#x6CD5;</span>

<span class="hljs-comment">//&#x5217;&#x8868;&#x5408;&#x5E76;</span>
List&lt;T&gt; list = Lists.combine(List&lt;T&gt; list1, List&lt;T&gt; list2); <span class="hljs-comment">//list1&#x548C;list2&#x5408;&#x5E76;&#x4E3A;&#x4E00;&#x4E2A;list</span>

<span class="hljs-comment">//&#x904D;&#x5386;</span>
Lists.each(list, <span class="hljs-keyword">new</span> OnWalk&lt;String&gt;() {
    <span class="hljs-meta">@Override</span>
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">boolean</span> <span class="hljs-title">process</span><span class="hljs-params">(<span class="hljs-keyword">int</span> index, String s, <span class="hljs-keyword">int</span> total)</span> </span>{
        <span class="hljs-comment">//index&#x662F;&#x4E0B;&#x6807;&#xFF0C; s&#x662F;&#x5F53;&#x524D;&#x5143;&#x7D20;&#xFF0C;total&#x662F;&#x4E00;&#x5171;&#x51E0;&#x4E2A;</span>
    }
});

<span class="hljs-comment">//&#x514B;&#x9686;&#xFF1A;&#x8FD4;&#x56DE;&#x4E00;&#x4E2A;&#x65B0;list&#xFF0C;&#x4F46;&#x5143;&#x7D20;&#x8FD8;&#x662F;&#x76F8;&#x540C;&#x7684;&#x5F15;&#x7528;</span>
List&lt;T&gt; list = Lists.combine(List&lt;T&gt; list1)
List&lt;T&gt; list = Lists.combine(T[] arr)

<span class="hljs-comment">//&#x904D;&#x5386;&#x5E76;&#x5220;&#x9664;&#x5143;&#x7D20;&#xFF1A;&#x5220;&#x9664;&#x4E3A;null&#x7684;&#x5B57;&#x7B26;&#x4E32;</span>
<span class="hljs-comment">//&#x6CE8;&#x610F;&#xFF0C;&#x5185;&#x90E8;&#x5B9E;&#x73B0;&#x662F;&#x590D;&#x5236;&#x4E86;&#x4E00;&#x4EFD;list&#xFF0C;&#x7136;&#x540E;&#x904D;&#x5386;&#x65B0;list&#xFF0C;&#x5728;&#x539F;list&#x57FA;&#x7840;&#x4E0A;&#x505A;remove</span>
List&lt;Object&gt; list =  Lang.list(<span class="hljs-string">&quot;true&quot;</span>, <span class="hljs-string">&quot;23&quot;</span>, <span class="hljs-string">&quot;ABC&quot;</span>, <span class="hljs-keyword">null</span>);
Lists.remove(list, <span class="hljs-keyword">new</span> OnWalk&lt;String&gt;() {
    <span class="hljs-meta">@Override</span>
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">boolean</span> <span class="hljs-title">process</span><span class="hljs-params">(<span class="hljs-keyword">int</span> index, String s, <span class="hljs-keyword">int</span> total)</span> </span>{
        <span class="hljs-keyword">if</span>(s == <span class="hljs-keyword">null</span>) <span class="hljs-keyword">return</span> <span class="hljs-keyword">true</span>;
        <span class="hljs-keyword">return</span> <span class="hljs-keyword">false</span>;
    }
});
</code></pre>
<h3 id="6-&#x8F6C;&#x6362;">6 &#x8F6C;&#x6362;</h3>
<pre><code class="lang-java"><span class="hljs-comment">//&#x7C7B;&#x578B;&#x8F6C;&#x6362;&#xFF0C;&#x5982;&#x679C;&#x51FA;&#x73B0;&#x5F02;&#x5E38;&#xFF0C;&#x5219;&#x8FD4;&#x56DE;&#x5BF9;&#x5E94;&#x7C7B;&#x578B;&#x7684;0</span>
<span class="hljs-keyword">int</span> i = Lang.toInt(<span class="hljs-string">&quot;23&quot;</span>);
<span class="hljs-keyword">long</span> l = Lang.toLong(<span class="hljs-string">&quot;23&quot;</span>)
<span class="hljs-keyword">double</span> d = Lang.toDouble(<span class="hljs-string">&quot;23.3&quot;</span>);
</code></pre>
<h3 id="7-&#x65E5;&#x671F;&#x8F6C;&#x6362;">7 &#x65E5;&#x671F;&#x8F6C;&#x6362;</h3>
<pre><code class="lang-java"><span class="hljs-comment">//&#x65E5;&#x671F;</span>
String date = Lang.toDate(<span class="hljs-string">&quot;yyyy-MM-dd&quot;</span>, <span class="hljs-string">&quot;1547232323&quot;</span>); <span class="hljs-comment">//&#x53C2;&#x6570;2&#x662F;&#x79D2;&#x6570;&#xFF0C;String&#x7C7B;&#x578B;</span>
String date = Lang.toDate(<span class="hljs-string">&quot;yyyy-MM-dd&quot;</span>, <span class="hljs-number">1547232323</span>); <span class="hljs-comment">//&#x53C2;&#x6570;2&#x662F;&#x79D2;&#x6570;&#xFF0C;long&#x7C7B;&#x578B;</span>
String date = Lang.toDate(<span class="hljs-string">&quot;yyyy-MM-dd&quot;</span>, <span class="hljs-keyword">new</span> Date());

<span class="hljs-comment">//&#x65F6;&#x95F4;&#x6233;&#xFF1A;&#x5F53;&#x524D;&#x6BEB;&#x79D2;</span>
<span class="hljs-keyword">long</span> timestamp = Lang.getTimeStamp();
</code></pre>
<h3 id="8-&#x5B57;&#x7B26;&#x4E32;&#x5DE5;&#x5177;&#x7C7B;&#xFF1A;strings">8 &#x5B57;&#x7B26;&#x4E32;&#x5DE5;&#x5177;&#x7C7B;&#xFF1A;Strings</h3>
<h4 id="&#x4ECE;&#x5404;&#x79CD;&#x6765;&#x6E90;&#x5F97;&#x5230;&#x5B57;&#x7B26;&#x4E32;">&#x4ECE;&#x5404;&#x79CD;&#x6765;&#x6E90;&#x5F97;&#x5230;&#x5B57;&#x7B26;&#x4E32;</h4>
<pre><code class="lang-java"><span class="hljs-comment">//&#x8BFB;&#x53D6;&#x8F93;&#x5165;&#x6D41;</span>
String s = Lang.fromStream(InputStream inputStream);

<span class="hljs-comment">//&#x62FC;&#x63A5;</span>
List&lt;String&gt; list = Lang.list(<span class="hljs-string">&quot;true&quot;</span>, <span class="hljs-string">&quot;23&quot;</span>, <span class="hljs-string">&quot;ABC&quot;</span>, <span class="hljs-keyword">null</span>);
String s = fromList(list, <span class="hljs-string">&quot;,&quot;</span>, <span class="hljs-keyword">true</span>); <span class="hljs-comment">//&#x8FD4;&#x56DE;true, 23, abc</span>
s = fromList(list, <span class="hljs-string">&quot;,&quot;</span>, <span class="hljs-keyword">false</span>); <span class="hljs-comment">//  &#x8FD4;&#x56DE;true, 23, abc, ,</span>

fromArray, fromSet&#x4E5F;&#x662F;&#x4E00;&#x4E2A;&#x9053;&#x7406;

<span class="hljs-comment">//&#x70B8;&#x88C2;</span>
String[] arr = Strings.split(src, delemeter);  <span class="hljs-comment">//&#x6309;&#x5206;&#x9694;&#x7B26;&#x70B8;</span>
List&lt;String&gt; list = String.split(&#x8F83;&#x957F;&#x5B57;&#x7B26;&#x4E32;, &#x4E00;&#x4E2A;&#x5143;&#x7D20;&#x6700;&#x957F;&#x591A;&#x5C11;);  <span class="hljs-comment">//&#x6309;&#x957F;&#x5EA6;&#x70B8;</span>
</code></pre>
<h4 id="&#x5404;&#x79CD;&#x6A21;&#x5F0F;&#x5339;&#x914D;">&#x5404;&#x79CD;&#x6A21;&#x5F0F;&#x5339;&#x914D;</h4>
<pre><code class="lang-java"><span class="hljs-comment">//&#x6BD4;&#x8F83;&#x5E38;&#x7528;&#x7684;&#x5B57;&#x7B26;&#x4E32;&#x683C;&#x5F0F;&#x5224;&#x65AD;</span>


<span class="hljs-comment">//&#x4E2D;&#x82F1;&#x6587;&#x76F8;&#x5173;</span>


<span class="hljs-comment">//&#x5168;&#x89D2;&#x534A;&#x89D2;&#x76F8;&#x5173;</span>
</code></pre>
<h4 id="ip&#x5730;&#x5740;&#x76F8;&#x5173;&#x8FD8;&#x6709;&#x4E00;&#x4E2A;&#x7C7B;&#xFF1A;inetaddressutils&#xFF0C;&#x4E5F;&#x662F;&#x5224;&#x65AD;&#x5404;&#x79CD;&#x683C;&#x5F0F;&#x7684;ip&#x5730;&#x5740;">IP&#x5730;&#x5740;&#x76F8;&#x5173;&#x8FD8;&#x6709;&#x4E00;&#x4E2A;&#x7C7B;&#xFF1A;InetAddressUtils&#xFF0C;&#x4E5F;&#x662F;&#x5224;&#x65AD;&#x5404;&#x79CD;&#x683C;&#x5F0F;&#x7684;IP&#x5730;&#x5740;</h4>
<h3 id="9-&#x624B;&#x673A;&#x8BBE;&#x5907;&#x5E7B;&#x8C61;&#xFF1A;phone">9 &#x624B;&#x673A;&#x8BBE;&#x5907;&#x5E7B;&#x8C61;&#xFF1A;Phone</h3>
<p>Phone&#x7C7B;&#x4EE3;&#x8868;&#x5F53;&#x524D;&#x624B;&#x673A;&#xFF0C;&#x63D0;&#x4F9B;&#x4E86;&#x5BF9;&#x624B;&#x673A;&#x7684;&#x8BBF;&#x95EE;</p>
<pre><code class="lang-java">Phone.isEmulator(); <span class="hljs-comment">//&#x662F;&#x5426;&#x6A21;&#x62DF;&#x5668;</span>
Phone.getPhoneNumber(); <span class="hljs-comment">//&#x5F97;&#x5230;&#x624B;&#x673A;&#x53F7;&#xFF0C;&#x4E00;&#x822C;&#x5F97;&#x4E0D;&#x5230;</span>
Phone.getCpuInfo(); <span class="hljs-comment">//&#x5F97;&#x5230;&#x5F53;&#x524D;cpu&#x4FE1;&#x606F;</span>
Phone.getDeviceId(); <span class="hljs-comment">//&#x7EFC;&#x5408;&#x591A;&#x79CD;&#x65B9;&#x5F0F;&#x5F97;&#x5230;&#x4E00;&#x4E2A;&#x552F;&#x4E00;&#x7684;&#x8BBE;&#x5907;ID</span>
Phone.getAccesstype(); <span class="hljs-comment">//&#x5F97;&#x5230;&#x5F53;&#x524D;&#x8054;&#x7F51;&#x65B9;&#x5F0F;</span>
Phone.getMac(); <span class="hljs-comment">//&#x5F97;&#x5230;Mac&#x5730;&#x5740;&#xFF0C;&#x9700;&#x8981;&#x6743;&#x9650;&#xFF1A;ACCESS_WIFI_STATE</span>
Phone.getLocAddress(); <span class="hljs-comment">//&#x5F97;&#x5230;&#x5F53;&#x524D;IP&#x5730;&#x5740;&#xFF0C;&#x53EF;&#x80FD;&#x4E0D;&#x662F;&#x771F;&#x6B63;&#x7684;&#x7F51;&#x5361;IP</span>
</code></pre>
<h3 id="10-&#x5F53;&#x524D;app&#x5E7B;&#x8C61;&#xFF1A;theapp">10 &#x5F53;&#x524D;APP&#x5E7B;&#x8C61;&#xFF1A;TheApp</h3>
<pre><code class="lang-java">TheApp&#x7C7B;&#x4EE3;&#x8868;&#x5F53;&#x524D;&#x5E94;&#x7528;&#xFF0C;&#x63D0;&#x4F9B;&#x4E86;&#x5BF9;&#x5E94;&#x7528;&#x7684;&#x8BBF;&#x95EE;
TheApp.getAppVersionName(); <span class="hljs-comment">//&#x5F97;&#x5230;&#x7248;&#x672C;&#x540D;</span>
TheApp.getAppVersionCode(); <span class="hljs-comment">//&#x5F97;&#x5230;&#x7248;&#x672C;&#x53F7;</span>
TheApp.isServiceRunning(Service&#x7684;<span class="hljs-class"><span class="hljs-keyword">class</span>)</span>; <span class="hljs-comment">//&#x67E5;&#x770B;&#x6307;&#x5B9A;service&#x662F;&#x5426;&#x5728;&#x8FD0;&#x884C;</span>
</code></pre>
<p><strong>&#x600E;&#x4E48;&#x77E5;&#x9053;&#x5F53;&#x524D;app&#x662F;&#x5426;&#x8FDB;&#x5165;&#x4E86;&#x540E;&#x53F0;&#xFF1F;</strong></p>
<p>&#x672C;&#x6765;&#x770B;&#x5230;&#x4E00;&#x4E2A;&#x5E93;&#xFF0C;&#x8BF4;&#x662F;&#x4E94;&#x79CD;&#x65B9;&#x6CD5;&#x5224;&#x65AD;&#x7A0B;&#x5E8F;&#x8FDB;&#x5165;&#x524D;&#x53F0;&#x8FD8;&#x662F;&#x540E;&#x53F0;&#xFF0C;&#x4F46;&#x8BD5;&#x4E86;&#x8BD5;&#xFF0C;&#x600E;&#x4E48;&#x8FD9;&#x4E48;&#x5361;&#x5462;
<a href="https://github.com/wenmingvs/AndroidProcess" target="_blank">https://github.com/wenmingvs/AndroidProcess</a></p>
<p>&#x5177;&#x4F53;&#x4EE3;&#x7801;&#x6CA1;&#x770B;&#xFF0C;&#x4F46;&#x9274;&#x4E8E;&#x5E76;&#x6CA1;&#x6709;&#x4E00;&#x4E2A;receiver&#x673A;&#x5236;&#x53EF;&#x4EE5;&#x77E5;&#x9053;&#x8FD9;&#x4E2A;&#x4FE1;&#x606F;&#xFF0C;&#x6240;&#x4EE5;&#x4F30;&#x8BA1;&#x662F;&#x505A;&#x4E86;&#x5927;&#x5FAA;&#x73AF;&#xFF0C;
&#x4E3A;&#x4E86;&#x4E0D;&#x505A;&#x5927;&#x5FAA;&#x73AF;&#xFF0C;&#x521D;&#x6B65;&#x4F30;&#x8BA1;&#x5F97;&#x8BB0;&#x5F55;&#x6240;&#x6709;Activity&#x7684;&#x5F53;&#x524D;&#x72B6;&#x6001;&#x624D;&#x884C;</p>
<p>&#x8FD9;&#x4E2A;&#x5DE5;&#x4F5C;&#x5982;&#x679C;&#x8981;&#x505A;&#xFF0C;&#x5C31;&#x5728;TheApp&#x91CC;&#x505A;</p>
<h3 id="11-json&#x5DE5;&#x5177;&#x7C7B;&#xFF1A;jsonutils">11 Json&#x5DE5;&#x5177;&#x7C7B;&#xFF1A;JsonUtils</h3>
<p>&#x57FA;&#x4E8E;FastJson&#xFF0C;&#x6CE8;&#x610F;&#xFF0C;&#x6CA1;&#x6709;&#x7528;type&#x6216;&#x8005;TypeToken&#x76F8;&#x5173;&#x7684;&#xFF0C;&#x6015;&#x63A5;&#x53E3;&#x4E0D;&#x53CB;&#x597D;</p>
<pre><code class="lang-java">List&lt;Bean&gt; list = JsonUtils.getBeanList(json, Bean.class);
Bean bean = JsonUtils.getBean(json, Bean.class);
</code></pre>
<h3 id="11-&#x5B89;&#x5353;&#x63D0;&#x4F9B;&#x7684;intent&#x548C;content&#xFF0C;receiver&#x7B49;&#xFF1A;-systemintent&#x548C;os&#x7C7B;">11 &#x5B89;&#x5353;&#x63D0;&#x4F9B;&#x7684;Intent&#x548C;Content&#xFF0C;Receiver&#x7B49;&#xFF1A; SystemIntent&#x548C;OS&#x7C7B;</h3>
<p>&#x6253;&#x5F00;&#x76F8;&#x673A;&#xFF0C;&#x6253;&#x5F00;&#x8BBE;&#x7F6E;&#xFF0C;&#x6253;&#x7535;&#x8BDD;&#xFF0C;&#x6253;&#x5F00;&#x6D4F;&#x89C8;&#x5668;&#x7B49;&#xFF0C;&#x6682;&#x65F6;&#x4E0D;&#x6574;&#x7406;&#x4E86;&#xFF0C;&#x56E0;&#x4E3A;&#xFF1A;
<strong>&#x8FD9;&#x4E2A;&#x7C7B;&#x662F;&#x8981;&#x662F;&#x5220;&#x9664;&#x7684;&#xFF0C;&#x56E0;&#x4E3A;&#x73B0;&#x5728;&#x5BF9;&#x5916;&#x63A5;&#x53E3;&#x4E0D;&#x591F;&#x53CB;&#x597D;&#xFF0C;&#x4F46;&#x56E0;&#x4E3A;&#x4E4B;&#x524D;&#x4EE3;&#x7801;&#x8FD8;&#x6709;&#x7528;&#xFF0C;&#x6240;&#x4EE5;&#x6682;&#x65F6;&#x7559;&#x7740;</strong></p>
<p>&#x8981;&#x4F5C;&#x4E3A;&#x4EE3;&#x66FF;&#x7684;&#x7C7B;&#x662F;&#xFF1A;OS&#xFF0C;&#x8868;&#x793A;&#x5F53;&#x524D;&#x7CFB;&#x7EDF;&#xFF0C;&#x8BF7;&#x4F18;&#x5148;&#x4F7F;&#x7528;&#x8FD9;&#x4E2A;</p>
<h3 id="12-&#x5176;&#x4ED6;">12 &#x5176;&#x4ED6;</h3>
<pre><code class="lang-java"><span class="hljs-comment">//&#x9707;&#x52A8;</span>
Lang.i_am_cold();

<span class="hljs-comment">//&#x8BFB;&#x53D6;&#x5F02;&#x5E38;</span>
String s = Lang.readThrowable(throwable);
</code></pre>
<h2 id="3-bitmaps&#x5DE5;&#x5177;&#x7C7B;">3 Bitmaps&#x5DE5;&#x5177;&#x7C7B;</h2>
<p>&#x63D0;&#x4F9B;&#x4E86;&#x89E3;&#x6790;&#x56FE;&#x7247;&#x7684;&#x57FA;&#x672C;&#x65B9;&#x6CD5;</p>
<h2 id="4-&#x89C2;&#x5BDF;&#x8005;&#x6A21;&#x5F0F;&#x652F;&#x6301;">4 &#x89C2;&#x5BDF;&#x8005;&#x6A21;&#x5F0F;&#x652F;&#x6301;</h2>
<p>Observable&#x548C;Observer&#xFF0C;&#x4EE5;&#x7EC4;&#x4EF6;&#x5F62;&#x5F0F;&#x63D0;&#x4F9B;&#xFF0C;&#x800C;&#x975E;&#x57FA;&#x7C7B;&#x5F62;&#x5F0F;</p>
<pre><code>///&#x53D1;&#x5E03;&#x8005;
protected Observable observable = new Observable();
public Observable getObservable(){
    return observable;
}

///&#x901A;&#x77E5;&#x8BA2;&#x9605;&#x8005;
getObservable().notifyDataChanged(this, &#x4EFB;&#x610F;&#x6570;&#x636E;);

///&#x8BA2;&#x9605;&#x8005;
v.getObservable().addObserver(new Observer() {
    @Override
    public void update(Observable observable, Object src, Object data) {
        setNotify(data.toString());
    }
});
</code></pre><h2 id="5-&#x65E5;&#x5FD7;">5 &#x65E5;&#x5FD7;</h2>
<p>Lang.log&#x7CFB;&#x5217;</p>
<p>Lang.raise</p>
<h2 id="6-json&#x652F;&#x6301;">6 Json&#x652F;&#x6301;</h2>
<p>&#x57FA;&#x4E8E;fastjson&#xFF1A;compile &apos;com.alibaba:fastjson:1.2.8&apos;</p>
<h2 id="7-&#x52A0;&#x5BC6;&#x89E3;&#x5BC6;">7 &#x52A0;&#x5BC6;&#x89E3;&#x5BC6;</h2>
<p>Md5Utils<br>DES</p>
<h2 id="5-file&#x76F8;&#x5173;">5 file&#x76F8;&#x5173;</h2>
<h2 id="6-configer">6 Configer</h2>
<h2 id="7-display">7 Display</h2>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="rxjava.html" class="navigation navigation-prev " aria-label="Previous page: RxJava">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="http.html" class="navigation navigation-next " aria-label="Next page: http">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"常用工具类","level":"2.3","depth":1,"next":{"title":"http","level":"2.4","depth":1,"path":"http.md","ref":"http.md","articles":[]},"previous":{"title":"RxJava","level":"2.2","depth":1,"path":"rxjava.md","ref":"rxjava.md","articles":[]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":[],"pluginsConfig":{"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"lang.md","mtime":"2017-04-09T11:00:28.202Z","type":"markdown"},"gitbook":{"version":"3.2.2","time":"2017-04-09T17:03:25.521Z"},"basePath":".","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="gitbook/gitbook.js"></script>
    <script src="gitbook/theme.js"></script>
    
        
        <script src="gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

